import {
  defineConfig,
  presetAttributify,
  presetIcons,
  presetTypography,
  presetUno,
  presetWebFonts,
  transformerDirectives,
  transformerVariantGroup,
} from "unocss";

export default defineConfig({
  shortcuts: [
    [
      "btn",
      "px-4 py-1  rounded inline-block bg-teal-600 text-white cursor-pointer hover:bg-teal-500 disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50",
    ],
    [
      "icon-btn",
      "inline-block cursor-pointer w-8 h-8 select-none opacity-75 transition duration-200 ease-in-out hover:opacity-100 hover:text-teal-600",
    ],
    ["wh-full", "w-full h-full"],
    ["h1", "text-xl! leading-10! break-words font-sans m-0 font-bold"],
    [
      "h2",
      "text-lg! leading-10! break-words p-0 h-auto overflow-x-hidden font-thin",
    ],
    ["h3", "opacity-50"],
    ["divide", "border-b-2 my-8"],
    ["divide_b", "border-b-1 border-b-cool-gray-200"],
    ["avatar", "rounded-50% block"],
  ],
  rules: [
    [
      /^wh-(\d+)$/,
      ([, d]) => ({
        width: `${Number(d) / 4}rem`,
        height: `${Number(d) / 4}rem`,
      }),
    ],
  ],
  presets: [
    presetUno(),
    presetAttributify(),
    presetIcons({
      warn: true,
    }),
    presetTypography(),
    presetWebFonts({
      fonts: {
        sans: "DM Sans",
        serif: "DM Serif Display",
        mono: "DM Mono",
      },
    }),
  ],
  transformers: [transformerDirectives(), transformerVariantGroup()],
  safelist: "prose prose-sm m-auto text-left".split(" "),
});
